<?php

namespace App\Http\Forms;

use App\Library\OSS;
use App\Modules\Order\Models\Order;
use App\Modules\Shop\Shop;
use App\Modules\User\Models\Admin;
use Illuminate\Support\Facades\Auth;
use Kris\LaravelFormBuilder\Form;

class OrderForm extends Form
{
    public function buildForm()
    {
        $this
            ->add('user_id', 'select', [
                'label' => "用户",
                'rules' => 'required|string',
                'choices' => [],
            ])
            ->add('type', 'select', [
                'label' => "跳转目标",
                'rules' => 'required|string',
                'choices' => $this->getData("typeData"),
            ])
            ->add('shop_id', 'hidden', [
            ])
            ->add('link_id', 'linkage', [
                'label' => "链接的商品",
                'rules' => 'required|integer',
                'attr' => ['class' => "form-control select2"],
                'url' => route('admin.search_type_good',['shop_id'=> $this->getData("shop_id")]),
                'choices' => [],
                'power' =>"type",
//                'power'=>"shop_id"
            ])
            ->add('price', 'text', [
                'label' => "订单价格",
                'rules' => 'required|numeric|min:0|max:9999999',
            ])

            ->add('bill', 'image_list', [
                'label' => "消费凭证",
                'rules' => 'nullable|array',
                'type' => 'bill',
            ])
            ->add('submit', 'submit', [
                'attr' => ['class' => "form-control btn btn-success"],
                'label' => '下一步',
            ]);
    }
}
